<div class="paging">
    <?php
    App::Import('Model', 'Candidate');
    $candidate = new Candidate();
    echo $this->Paginator->options(array('update' => '#content', 'evalScripts' => false));
    echo $this->Paginator->prev('< ' . __('Anterior'), array(), null, array('class' => 'prev disabled'));
    echo $this->Paginator->numbers(array('separator' => ''));
    echo $this->Paginator->next(__('Siguiente') . ' >', array(), null, array('class' => 'next disabled'));
    ?>
</div>
<br>
<table >
    <tbody>
        <tr>
            <td colspan="2">
                <?php
                echo $paginator->counter(array(
                    'format' => 'Página %page% de %pages%, Mostrando %current% registros de %count% totales, empezando en %start%, terminando en %end%'
                        )
                );
                ?> 
            </td>
        </tr>
</table>
<table id="tabla">
    <thead>
        <tr>
            <th><?php echo $this->Paginator->sort('Nombre del banco', 'BankAccount.nombre_banco'); ?></th>
            <th><?php echo $this->Paginator->sort('Número de cuenta', 'BankAccount.numero_cuenta'); ?></th>
            <th><?php echo $this->Paginator->sort('Nombre del titular', 'BankAccount.nombre_titular'); ?></th>
            <th><?php echo $this->Paginator->sort('Documento titular', 'BankAccount.documento_titular'); ?></th>
            <th><?php echo $this->Paginator->sort('Tipo cuenta', 'BankAccount.tipo_cuenta'); ?></th>
            <th colspan ="2"></th>

        </tr>
    </thead>
    <tbody>
        <?php foreach ($BankAccounts as $BankAccount): ?>
            <tr>
                <?php
                //Busco el candidato que pertenece a esta cuenta.
                $aspirante = $candidate->find('first', array('conditions' => array('Candidate.id' => $BankAccount['BankAccount']['candidate_id']), 'fields' => array('nro_ident', '1er_apellido', '2do_apellido', '1er_nombre')));
                ?>
                <td><?php echo $BankAccount['BankAccount']['nombre_banco']; ?></td>
                <td><?php echo $BankAccount['BankAccount']['numero_cuenta']; ?></td>
                <td><?php echo $aspirante['Candidate']['1er_nombre'] . " " . $aspirante['Candidate']['1er_apellido'] . " " . $aspirante['Candidate']['2do_apellido']; ?></td>
                <td><?php echo $aspirante['Candidate']['nro_ident']; ?></td>
                <td><?php echo $BankAccount['BankAccount']['tipo_cuenta']; ?></td>

                <td><?php echo $this->Ajax->link('Editar', array('controller' => 'BankAccounts', 'action' => 'edit', $BankAccount["BankAccount"]["id"]), array('class' => 'actions', 'update' => 'content', 'indicator' => 'loading')); ?></td>

                <td>
                    <?php if (file_exists($BankAccount['BankAccount']['adjunto'] . ".pdf")): ?>
                        <a href="<?php echo $BankAccount['BankAccount']['adjunto'] . ".pdf" ?>" target="blank" class="actions" >Adjunto</a>
                    <?php endif; ?>
                </td>

            </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php echo $this->Js->writeBuffer(); ?>
<br>
<?php echo $this->Ajax->link('Adicionar', array('controller' => 'BankAccounts', 'action' => 'add', $proyect_id), array('update' => 'content', 'indicator' => 'loading', 'class' => 'actions')); ?>
